﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MyBet.Web;
using System.ServiceModel.DomainServices.Client;
using System.ServiceModel.DomainServices.Client.ApplicationServices;
using System.Collections.Generic;
using MyBet.Helpers;

namespace MyBet.Class
{
    //public struct CommentsBox
    //{
    //    private Groupbox.GroupBox _groupBox;
    //    private CommentObject _comment;

    //    public Groupbox.GroupBox GroupControl
    //    {
    //        get { return _groupBox; }
    //        set { _groupBox = value; }
    //    }
    //    public CommentObject Comment
    //    {
    //        get { return _comment; }
    //        set { _comment = value; }
    //    }
    //}

    //public class Comments
    //{
    //    private CommentContext commentContext = new CommentContext();
    //    private List<CommentsBox> postedComments = new List<CommentsBox>();
    //    private Grid _parent;
    //    private Groupbox.GroupBox _firstChild;

    //    public Groupbox.GroupBox FirstChild
    //    {
    //        get { return _firstChild; }
    //        set { _firstChild = value; }
    //    }

    //    public Grid Parent
    //    {
    //        get { return _parent; }
    //        set { _parent = value; }
    //    }

    //    private string GetCommentHeader(CommentObject c)
    //    {
    //        string post;
    //        if (c.CommentUserName == null)
    //        {
    //            post = "";
    //        }
    //        else
    //        {
    //            post = String.Format("{0} {1}", LangHelper.GetString("PostedBy"), c.CommentUserName);
    //        }
    //        return String.Format("{1} - {0} {2}", c.Title, c.CommentDate.ToShortDateString(), post);
    //    }

    //    public Comments(Grid parent, Groupbox.GroupBox firstchild)
    //    {
    //        Parent = parent;
    //        FirstChild = firstchild;
    //    }

    //    /// <summary>
    //    /// Load Five last blog comments
    //    /// </summary>
    //    public void Load()
    //    {
    //        // Query that gets the list of points from 
    //        // the database. 
    //        var queryhist = commentContext.GetCommentsQuery(0);
    //        // Execute the query. 
    //        commentContext.Load(queryhist, commentsLoad_Completed, null);
    //    }

    //    /// <summary>
    //    /// Culture management
    //    /// </summary>
    //    public void UpdateCulture()
    //    {
    //        // Update comments
    //        foreach (CommentsBox cb in postedComments)
    //        {
    //            cb.GroupControl.Header = GetCommentHeader(cb.Comment);
    //        }
    //    }

    //    private void commentsLoad_Completed(LoadOperation<CommentObject> operation)
    //    {
    //        if (!operation.IsCanceled)
    //        {
    //            if (!operation.HasError)
    //            {
    //                postedComments.Clear();
    //                int i = 0;
    //                double lastTop = FirstChild.Margin.Top + FirstChild.Height;
    //                foreach (MyBet.Web.CommentObject c in operation.Entities)
    //                {
    //                    Groupbox.GroupBox gb = new Groupbox.GroupBox();
    //                    CommentsBox cb = new CommentsBox();
    //                    gb.Margin = new Thickness(30, lastTop + 20, 54, 0);
    //                    gb.Header = GetCommentHeader(c);
    //                    gb.Height = c.Height;
    //                    gb.VerticalAlignment = VerticalAlignment.Top;
    //                    lastTop += c.Height + 20;
    //                    Parent.Children.Add(gb);
    //                    cb.GroupControl = gb;
    //                    cb.Comment = c;
    //                    postedComments.Add(cb);
    //                    i++;
    //                }
    //            }
    //        }
    //    }

    //}
}
